package org.quickserver.net.client.loaddistribution.impl;

import java.util.List;
import java.util.logging.Logger;
import org.quickserver.net.client.ClientInfo;
import org.quickserver.net.client.Host;
import org.quickserver.net.client.HostList;
import org.quickserver.net.client.loaddistribution.LoadPattern;
















public class FirstActiveLoadPattern
  implements LoadPattern
{
  private static final Logger logger = Logger.getLogger(FirstActiveLoadPattern.class.getName());


  
  private HostList hostList;



  
  public HostList getHostList() { return this.hostList; }

  
  public void setHostList(HostList hostList) { this.hostList = hostList; }

  
  public Host getHost(ClientInfo clientInfo) {
    List<Host> activeList = getHostList().getActiveList();
    
    if (activeList == null || activeList.isEmpty()) {
      logger.warning("No active list available to service requests");
      return null;
    } 
    
    return activeList.get(0);
  }
}
